package Action;

import Entities.DoeBookEntity;
import Service.BookDetailService;
import com.opensymphony.xwork2.Action;

import java.util.List;

//返回图书详细信息Action
public class BookDetailAction implements Action {
    private String book_id;
    private BookDetailService bookDetailService;
    private DoeBookEntity doeBookEntity;

    public List<String> getBookRefTags() {
        return bookRefTags;
    }

    public void setBookRefTags(List<String> bookRefTags) {
        this.bookRefTags = bookRefTags;
    }

    private List<String> bookRefTags;

    public DoeBookEntity getDoeBookEntity() {
        return doeBookEntity;
    }

    public void setDoeBookEntity(DoeBookEntity doeBookEntity) {
        this.doeBookEntity = doeBookEntity;
    }

    public BookDetailService getBookDetailService() {
        return bookDetailService;
    }

    public void setBookDetailService(BookDetailService bookDetailService) {
        this.bookDetailService = bookDetailService;
    }

    public String getBook_id() {
        return book_id;
    }

    public void setBook_id(String book_id) {
        this.book_id = book_id;
    }


    @Override
    public String execute() throws Exception {
        if (book_id == null)
            return ERROR;
        else {
            setDoeBookEntity(bookDetailService.getBookByBookID(book_id));
            setBookRefTags(bookDetailService.getRefTagsByBookID(book_id));
        }
        return SUCCESS;
    }
}
